<script type="text/javascript">
function SelectAll(checkboxall)
{
	$(".updatecheckbox").attr("checked", checkboxall.checked);
}
</script>

<div class="deal">
<div class="deal_content_top"></div>
<div class="deal_content">
<h3>Quản lý bình luận</h3>

<div align="center" style="background-color: white;">
	<form action="<?php echo $this->baseUrl("index.php/admin_cms/comment") ?>" method="get">
		<table>
			<tr>
				<td><strong>Tìm kiếm</strong></td>
				<td>
					<input type="text" name="filter" value="<?php if(isset($this->filter)) echo $this->filter; ?>" />
				</td>
				<td>
					<input type="submit" value="Tìm" />
				</td>
			</tr>
		</table>
	</form>
</div>

<table class="table-style" style="width: 100%;" cellpadding="5px"
	cellspacing="0">
	<tbody>
		<tr class="table-title">
			<td><input type="checkbox" onchange="SelectAll(this);" /></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/comment") ?>?by=c.comment_id&order=<?php echo ($this->by != "c.comment_id" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">ID</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/comment") ?>?by=d.deal_title&order=<?php echo ($this->by != "d.deal_title" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Nơi bình luận</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/comment") ?>?by=c.content&order=<?php echo ($this->by != "c.content" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Nội dung</a></td>
			<td>&nbsp;</td>
		</tr>
		<?php
		if (count($this->paginator) == 0) {
			echo "<tr><td colspan='3' align='center'>No comments</td></tr>";
		} else {
			?>
			<form action="" method="post">
			<?php $i = 0 ?>
			<?php foreach ($this->paginator as $comment): ?>
			<?php $i++ ?>
		<tr class="<?php echo $i % 2 == 0 ? 'even' : 'odd' ?>">
			<td><input class="updatecheckbox" type="checkbox" name="checkbox[]" value="<?php echo $comment->comment_id ?>" /></td>
			<td><?php echo $comment->comment_id ?></td>
			<td>
				<a href="<?php echo $this->baseUrl('index.php/cms/index/deal/id/' . $comment->deal_id . '#comment') ?>">
					<?php
					if(strlen($comment->deal_title) < 30)
					{
						echo $comment->deal_title;
					}
					else
					{
						echo substr($comment->deal_title, 0, 30) . " ...";
					}
					?>
				</a>
			</td>
			<td>
				<?php
					if(strlen($comment->content) < 50)
					{
						echo $comment->content;
					}
					else
					{
						echo substr($comment->content, 0, 50) . " ...";
					}
					?>
			</td>			
			<td align="right">
			<a
				href="<?php echo $this->baseUrl('index.php/admin_cms/comment/detail/id/' . $comment->comment_id) ?>">
				<img title="Xem chi tiết" alt="Xem chi tiết"
				src="<?php echo $this->baseUrl('public/images/comment.png') ?>"> </a>
			<a
				href="<?php echo $this->baseUrl('index.php/admin_cms/comment/edit/id/' . $comment->comment_id) ?>">
			<img title="Edit" alt="Edit"
				src="<?php echo $this->baseUrl('public/images/edit.png') ?>"> </a> 
				<a href="<?php echo $this->baseUrl('index.php/admin_cms/comment/delete/id/' . $comment->comment_id) ?>"
				onclick="if(!confirm('Delete ?',''))return false;"> <img title="Delete"
				alt="Delete"
				src="<?php echo $this->baseUrl('public/images/delete.png') ?>"> </a>
				
				<?php if($comment->status == 0): ?>
				<a
				href="<?php echo $this->baseUrl('index.php/admin_cms/comment/public/id/' . $comment->comment_id) ?>"
				onclick="if(!confirm('Public ?',''))return false;"> <img title="Make comment public"
				alt="Delete"
				src="<?php echo $this->baseUrl('public/images/private.png') ?>"> </a>
				<?php else: ?>
				<a
				href="<?php echo $this->baseUrl('index.php/admin_cms/comment/private/id/' . $comment->comment_id) ?>"
				onclick="if(!confirm('Private ?',''))return false;"> <img title="Make comment private"
				alt="Delete"
				src="<?php echo $this->baseUrl('public/images/public.png') ?>"> </a>
				<?php endif; ?>
			</td>
		</tr>
		<?php endforeach ?>
		<tr>
			<td colspan="5">
				<?php $comment_status = Zend_Registry::get("comment_status"); ?>
				Trạng thái
				&nbsp;&nbsp;
				<select name="status">
					<?php
					for($i = 0; $i < count($comment_status); $i++)
					{
						echo "<option value='$i'>{$comment_status[$i]}</option>";
					}
					?>
				</select>
				&nbsp;&nbsp;
				<input type="submit" value="Cập nhật" />
			</td>
		</tr>
		</form>
		<?php } ?>
	</tbody>
</table>
		<?php echo $this->placeholder('paging') ?>
<?php echo $this->paginator; ?>

</div>

<div class="deal_content_bottom"></div>
</div>
